package com.px.user.mapper;

import com.px.user.entity.Vote;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository
public interface VoteMapper {

    @Select("select createTime from vote where userId=#{userId} and roomId=#{roomId} order by createTime desc limit 1")
    Vote findByUserId(Map para);

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into vote (userId,roomId,updown) values (#{userId},#{roomId},#{updown})")
    void insert(Vote vote);

    @Delete("delete from vote where roomId=#{id}")
    void delete(Long id);
}
